'use strict';

/**
 * schema
 * @description user 数据格式校验
 */

// 配置规则
module.exports = {
  type: 'object',
  // 属性
  properties: {
    userName: {
      type: 'string',
      minLength: 5,
      maxLength: 255,
      pattern: '^[a-zA-Z0-9][a-zA-Z0-9_]+$',
    },
    password: {
      type: 'string',
      minLength: 5,
      maxLength: 20,
      pattern: '^[a-zA-Z0-9][a-zA-Z0-9_]+$',
    },
    gender: {
      type: 'number',
      minimum: 1,
      maximum: 3,
    },
    nickName: {
      type: 'string',
      minLength: 1,
      maxLength: 20,
    },
    avatar: {
      type: 'string',
      maxLength: 255,
    },
    city: {
      type: 'string',
      maxLength: 8,
      minLength: 2,
    },
  },
  $async: true, // 异步
  additionalProperties: true,
};
